/*
 * Copyright (c) 2009. Silenus Consultoria, S.L.
 */
package es.silenus.detecta.model;

import java.io.Serializable;


/**
 * A knowledge unit form question answer. Data is only 0/1 Persistent class, read-write.
 *
 * @author <a href="mailto:malonso@silenus-consultoria.es">Mariano Alonso</a>
 *
 * @since 22-mar-2009 11:04:04
 */
public class SurveyUnitAnswerImported implements Serializable {
	/**
	 * The id
	 */
	private SurveyUnitAnswerImportedId id;

	/**
	 * The status.
	 */
	private SurveyAnswerValidation status;

	/**
	 * The preference.
	 */
	private TrainingPreference preference;

	/**
	 * The id question.
	 */
	private Long question;

	/**
	 * The id question.
	 */
	private String questionCode;

/**
   * Constructor.
   */
	public SurveyUnitAnswerImported() {
		id = new SurveyUnitAnswerImportedId();
		status = SurveyAnswerValidation.INVALID;
		preference = TrainingPreference.PRESENTIAL;
	}

	/**
	 * Retrieves the id.
	 *
	 * @return the id.
	 */
	public SurveyUnitAnswerImportedId getId() {
		return id;
	}

	/**
	 * Sets the id.
	 *
	 * @param id the id.
	 */
	public void setId(final SurveyUnitAnswerImportedId id) {
		this.id = id;
	}

	/**
	 * Retrieves the status.
	 *
	 * @return the status.
	 */
	public SurveyAnswerValidation getStatus() {
		return status;
	}

	/**
	 * Sets the status.
	 *
	 * @param status the status.
	 */
	public void setStatus(final SurveyAnswerValidation status) {
		this.status = status;
	}

	/**
	 * Retrieves the preference.
	 *
	 * @return the preference.
	 */
	public TrainingPreference getPreference() {
		return preference;
	}

	/**
	 * Sets the preference.
	 *
	 * @param preference the preference.
	 */
	public void setPreference(final TrainingPreference preference) {
		this.preference = preference;
	}

	/**
	 * Retrieves the question.
	 *
	 * @return the question.
	 */
	public Long getQuestion() {
		return question;
	}

	/**
	 * Sets the question.
	 *
	 * @param question the question.
	 */
	public void setQuestion(final Long question) {
		this.question = question;
	}

	/**
	 * Retrieves the question.
	 *
	 * @return the question.
	 */
	public String getQuestionCode() {
		return questionCode;
	}

	/**
	 * Sets the question.
	 *
	 * @param question the question.
	 */
	public void setQuestionCode(final String question) {
		this.questionCode = question;
	}

	/**
	 * Retrieves the header.
	 *
	 * @return the header.
	 */
	public SurveyAnswerHeaderImported getHeader() {
		return getId().getHeader();
	}

	/**
	 * Sets the header.
	 *
	 * @param header the header.
	 */
	public void setHeader(final SurveyAnswerHeaderImported header) {
		getId().setHeader(header);
	}

	/**
	 * Retrieves the question number.
	 *
	 * @return the question number.
	 */
	public int getQuestionNumber() {
		return getId().getQuestionNumber();
	}

	/**
	 * Sets the question number.
	 *
	 * @param questionNumber the question number.
	 */
	public void setQuestionNumber(int questionNumber) {
		getId().setQuestionNumber(questionNumber);
	}

	/**
	 * Checks if objects are equal.
	 *
	 * @param o other object.
	 *
	 * @return true if equal, false otherwise.
	 */
	@Override
	public boolean equals(Object o) {
		if(this == o) {
			return true;
		}

		if(!(o instanceof SurveyUnitAnswerImported)) {
			return false;
		}

		SurveyUnitAnswerImported that = (SurveyUnitAnswerImported)o;

		if((getId() != null) ? (!getId().equals(that.getId())) : (that.getId() != null)) {
			return false;
		}

		return true;
	}

	/**
	 * Calculates the hash of this instance.
	 *
	 * @return the hash code.
	 */
	@Override
	public int hashCode() {
		return (getId() != null) ? getId().hashCode() : 0;
	}
}
